package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.simple.ProjectMemberSimple;
import com.nbsaas.boot.project.data.entity.ProjectMember;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 项目成员-列表对象转换器
 */

public class ProjectMemberSimpleConvert implements Converter<ProjectMemberSimple, ProjectMember> {


    @Override
    public ProjectMemberSimple convert(ProjectMember source) {
        ProjectMemberSimple result = new ProjectMemberSimple();


        try {
            if (source.getMember() != null) {
                result.setMember(source.getMember().getId());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getProject() != null) {
                result.setProject(source.getProject().getId());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getMember() != null) {
                result.setMemberName(source.getMember().getName());
            }
        } catch (Exception ignored) {
        }

        result.setId(source.getId());

        try {
            if (source.getProject() != null) {
                result.setProjectName(source.getProject().getName());
            }
        } catch (Exception ignored) {
        }

        result.setAddDate(source.getAddDate());
        result.setLastDate(source.getLastDate());


        return result;
    }

}